package com.shunli.cterminal.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.examples.core.mybatis.mapper.KyLambdaQueryWrapper;
import com.shunli.cterminal.entity.ExpDO;
import com.shunli.cterminal.model.req.ExpReq;

import java.util.List;

/**
 * ab实验 Mapper
 *
 * @author 后台管理员
 */
@DS("adEngine")
public interface ExpMapper extends BaseMapper<ExpDO> {

    default List<ExpDO> getExpList(ExpReq reqVO) {
        return selectList(new KyLambdaQueryWrapper<ExpDO>()
                .eqIfPresent(ExpDO::getAppId, reqVO.getAppId())
                .eqIfPresent(ExpDO::getLayerCode, reqVO.getLayerCode())
                .eqIfPresent(ExpDO::getExpCode, reqVO.getExpCode())
                .likeIfPresent(ExpDO::getExpName, reqVO.getExpName())
                .eqIfPresent(ExpDO::getExpRate, reqVO.getExpRate())
                .eqIfPresent(ExpDO::getExpGroupCnt, reqVO.getExpGroupCnt())
                .eqIfPresent(ExpDO::getLayerRateBucketIds, reqVO.getLayerRateBucketIds())
                .betweenIfPresent(ExpDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(ExpDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(ExpDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(ExpDO::getExpStatus, reqVO.getExpStatus())
                .eqIfPresent(ExpDO::getSceneCode, reqVO.getSceneCode())
                .inIfPresent(ExpDO::getSceneCode, reqVO.getSceneCodeList())
                .eqIfPresent(ExpDO::getIdType, reqVO.getIdType())
                .inIfPresent(ExpDO::getExpStatus, reqVO.getExpStatusList())
                .inIfPresent(ExpDO::getId, reqVO.getExpIdList())
                .orderByDesc(ExpDO::getId));
    }
}